/*******************************************************************************
* Project: QSAR(Cute Software Architecture) 
*
* Copyright: Copyright(C) 2024 by YuetingBen, All Rights Reserved
*
* File name: AppTest.c
*
* Brief: ;
*
* Author: Yueting.Ben
*
* Module: AppTest
*
*******************************************************************************/

/** HEADER FILES **/
#include "AppTest.h"


/** MACRO DEFINITION **/


/** TYPEDEF DEFINITION **/


/** LOCAL DATA DECLARATION **/


/** GLOBAL DATA DECLARATION **/


/** LOCAL FUNCTION DECLARATION **/


/** GLOBAL FUNCTION DECLARATION **/
void AppTest_GetVersionInfo(
    Std_VersionInfoType* versionInfo
);


/** LOCAL DATA **/


/** GLOBAL DATA **/


/** LOCAL FUNCTION **/


/** GLOBAL FUNCTION **/

/*******************************************************************************
* -Name            AppTest_GetVersionInfo
* -Brief           Returns the version information of this module 
* -Details         None
* -Param[out]      versioninfo: Pointer to the version information of this module
* -Return          None          
*******************************************************************************/
void AppTest_GetVersionInfo(
    Std_VersionInfoType* versionInfo
)
{
    versionInfo->vendorID = (uint16)YSAR_VENDOR_ID;
    versionInfo->moduleID = (uint8)APPTEST_MODULE_ID;
    versionInfo->sw_major_version = (uint8)APPTEST_SW_MAJOR_VERSION;
    versionInfo->sw_minor_version = (uint8)APPTEST_SW_MINOR_VERSION;
    versionInfo->sw_patch_version = (uint8)APPTEST_SW_PATCH_VERSION;
}

/*******************************************************************************
* -Name            AppTest_MainFunction
* -Brief           Processes for testing
* -Details         None
* -Return          None
*******************************************************************************/
void AppTest_MainFunction(
    void
)
{
    static uint8 testTimer;
    static uint8 otherCan1SignalC;
    static uint8 otherCan1SignalCOld;
    static uint8 writingData[5] = {0xA1, 0xA1, 0xA1, 0xA1, 0xA1};
    static uint8 readData[5];

    if(testTimer >= 100u)
    {
        AppCom_GetSignal_Other_Can1_SignalC((uint8*)&otherCan1SignalC);
        if(otherCan1SignalCOld != otherCan1SignalC)
        {
            if(0x01 == otherCan1SignalC)
            {
                Dem_SetEventStatus(AppTestConf_DemEventId_DTC_0x000001, DEM_EVENT_STATUS_PREPASSED);
                NvM_WriteBlock(0x01, writingData);
            }
            else if(0x02 == otherCan1SignalC)
            {
                Dem_SetEventStatus(AppTestConf_DemEventId_DTC_0x000001, DEM_EVENT_STATUS_PREFAILED);
                NvM_ReadBlock(0x01, readData);
            }
            else if(0x03 == otherCan1SignalC)
            {
                Dem_SetEventStatus(AppTestConf_DemEventId_DTC_0x000002, DEM_EVENT_STATUS_PREPASSED);
            }
            else if(0x04 == otherCan1SignalC)
            {
                Dem_SetEventStatus(AppTestConf_DemEventId_DTC_0x000002, DEM_EVENT_STATUS_PREFAILED);
            }
            else
            {
                /* Do nothing */
            }
        }
        testTimer = 0u;

        otherCan1SignalCOld = otherCan1SignalC;
    }
    else
    {
        testTimer++;
    }
}

